<template>
  <div class="query">
    <van-nav-bar
      title="库位查询"
      left-text="返回"
      left-arrow
      @click-left="onClickLeft"
    />
    <div style="margin-bottom: 20px; padding: 0 10px">
      <van-cell-group>
        <van-field
          v-model="current_location_name"
          label="库位名称"
          size="large"
          clearable
          placeholder="请扫描当前库位名"
          required
        />
      </van-cell-group>
    </div>
    <div style="margin: 0 15px">
      <van-button size="large" type="primary" @click="search">查 询</van-button>
    </div>
    <div style="margin: 20px 0; padding: 0 10px">
      <van-cell-group>
        <van-field v-model="object_name" label="dolly号" size="large" />
      </van-cell-group>
    </div>
  </div>
</template>

<script>
import { QueryLocation } from "@/api/api";

export default {
  name: "LibraryLocationQuery",
  data: () => {
    return {
      object_name: "",
      current_location_name: "",
    };
  },
  watch: {},
  created() {},
  async mounted() {
    this.current_location_name = sessionStorage.getItem("QureyHtml");
  },
  destroyed: function () {},
  methods: {
    onClickLeft() {
      console.log("onClickLeft");
      this.$router.replace("/home");
    },
    search() {
      console.log(QueryLocation);
      const params = {
        current_location_name: this.current_location_name,
      };
      sessionStorage.setItem("QureyHtml", this.current_location_name);
      QueryLocation(params).then((res) => {
        console.log("QueryLocation==res", res);
        // if (res.code == 0) {
          this.object_name = res.body.data[0].object_name;
          // this.object_name = res.data[0].object_name;
        // }
      });

      //   api
      //     .QueryLocation(params)
      //     .then((res) => {
      //       console.log("QueryLocation==res", res);
      //     })
      //     .catch((err) => {
      //       console.log("QueryLocation==err", res);
      //     });
    },
  },
};
</script>

<style scoped>
.query {
  /* padding: 0 10px; */
  /* background: #eee; */
}
</style>
